﻿using System.Data;
using Habanero.BO;
using Habanero.BO.ClassDefinition;
using Habanero.BO.Loaders;
using NUnit.Framework;
using UseCaseManager.BO;
using UseCaseManager.Logic;
using UseCaseManager.Test.BO;

namespace UseCaseManager.Test.Logic
{
    [TestFixture]
    public class TestCreateXml
    {
        //Project Name
        //Package Name
        //Use Case Number	
        //Use Case Name	
        //Event(Trigger)	
        //Response(Use Case Steps)	
        [TestFixtureSetUp]
        public virtual void TestFixtureSetup()
        {
            //Clear and Load Class Defs
            TestUtils.TestFixtureSetup();
        }

        [SetUp]
        public virtual void SetupTest()
        {
            //-------------------------------------------------------------------------------------
            // You can choose here whether to run against a database or whether to use an in-memory
            // database for all the tests, which runs quickly. It doesn't however check that
            // your database has the correct structure, which is partly the purpose of these tests.
            // The generated tests do already use an in-memory database where possible.
            // In your custom tests, you can set them to use an in-memory database by copying the
            // line to the first line of your test.
            //-------------------------------------------------------------------------------------
            //BORegistry.DataAccessor = new DataAccessorDB();
        //Sets up In memory, clears business object manager
            TestUtils.TestSetup();
        }
        [Test]
        public void Test_CreatesValidProjectUsesCasesXml()
        {
            //---------------Set up test -----------------------
            //Sets up a hierarchy of objects 1 per relevant level with associations
            Project project = TestUtilsProject.CreateSavedProject();
            Package package = TestUtilsPackage.CreateUnsavedValidPackage();
            UseCase useCase = TestUtilsUseCase.CreateSavedUseCase();
            UseCaseStep useCaseStep = TestUtilsUseCaseStep.CreateUnsavedValidUseCaseStep();
            useCase.UseCaseSteps.Add(useCaseStep);
            useCase.Save();
            package.UseCases.Add(useCase);
            project.Packages.Add(package);
            project.Save();
            //---------------Assert pre conditions -------------
            Assert.AreEqual(1,project.Packages.Count);
            Assert.AreEqual(1,package.UseCases.Count);
            Assert.AreEqual(1,useCase.UseCaseSteps.Count);
            //---------------Execute Test ----------------------
            CreateXml.ProjectUseCases(project);
            //---------------Test Result -----------------------
            //use assert file exists method 
        }
    }
}
